package test00.test05.t04;

import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author lzp
 * @Date 2024-04-10
 */
public class Test {


    public static void main(String[] args) {
        String email = "12345@qq.com";

        Predicate<String> predicate = (e) ->{
            // 1 实例化正则表达式   []代表范围 {最少几个,最多几个}代表数量
            Pattern pattern = Pattern.compile("[a-zA-Z0-9_]{5,20}@[a-zA-Z0-9_]{2,10}\\.\\w{2,10}");

            Matcher matcher = pattern.matcher(e);

            return matcher.matches();
        };

        System.out.println(predicate.test(email)?"email合法":"email非法");

    }
}
